﻿#region Copyright 2006-2008 FI Ltd. All rights reserved.

// ================================================================================================
// Copyright © 2006-2008 FI Ltd. All rights reserved.
//
// SYSTEM NAME	: FI.Net Application Framework
// COMPONENT ID	: FI.Security
// COMPONENT DESC:		
//
// CREATED DATE/BY:		18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ================================================================================================

#endregion

using System;
using System.Runtime.Serialization;
using FI.Core;
using FI.Core.ApplicationContexts;

namespace FI.Core
{
    /// <summary>
    /// Presents an audit infomation.
    /// </summary>
    [Serializable]
    [DataContract(Namespace=Constants.Namespace)]
    public class AuditInfo
    {       

        /// <summary>
        /// Initializes a new instance of the <see cref="AuditInfo"/> class.
        /// </summary>
        /// <param name="versionNo">The version of current object.</param>
        /// <param name="transactionId">The transaction id of update.</param>
        /// <param name="createdBy">The user who create the user.</param>
        /// <param name="createdTime">The date the user is created.</param>
        /// <param name="lastUpdatedBy">The user who update the user.</param>
        /// <param name="lastUpdatedTime">The last date the user is updated.</param>
        public AuditInfo(int versionNo, string transactionId, string createdBy, DateTime createdTime,
                         string lastUpdatedBy, DateTime lastUpdatedTime)
        {
            VersionNo = versionNo;
            TransactionId = transactionId;
            CreatedBy = createdBy;
            CreatedTime = createdTime;
            LastUpdatedBy = lastUpdatedBy;
            LastUpdatedTime = lastUpdatedTime;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AuditInfo"/> class.
        /// </summary>
        public AuditInfo()
            : this(1, ApplicationContext.Current.TransactionId,
                ApplicationContext.Current.UserName, TimeConverter.CurrentDateTime,
                ApplicationContext.Current.UserName, TimeConverter.CurrentDateTime)
        { }

        /// <summary>
        /// Gets the version of current object
        /// </summary>
        /// <value>The version no.</value>
        [DataMember]
        public  int VersionNo { get; set; }

        /// <summary>
        /// Gets or sets the transaction id of update. Transaction id will be generated by transaction module.
        /// </summary>
        /// <value>The transaction id.</value>
        [DataMember]
        public  string TransactionId { get; set; }

        /// <summary>
        /// Gets or sets the user who create the user. It should be the primary key of the user.
        /// </summary>
        /// <value>The created by.</value>
        [DataMember]
        public  string CreatedBy { get; set; }

        /// <summary>
        /// Gets or sets the date the user is created.
        /// </summary>
        /// <value>The credted time.</value>
        [DataMember]
        public  DateTime CreatedTime { get; set; }

        /// <summary>
        /// Gets or sets the user who update the user. It should be the primary key of the user.
        /// </summary>
        /// <value>The last updated by.</value>
        [DataMember]
        public  string LastUpdatedBy { get; set; }

        /// <summary>
        /// Gets or sets the last date the user is updated.
        /// </summary>
        /// <value>The last updated time.</value>
        [DataMember]
        public  DateTime LastUpdatedTime { get; set; }
    }
}